package com.feducation.controller;

import com.feducation.entity.Tauth;
import com.feducation.entity.Tuser;
import com.feducation.enums.GenderEnum;
import com.feducation.enums.UserTypeEnum;
import com.feducation.service.ITauthService;
import com.feducation.service.ITuserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试controller
 */
@RestController
@RequestMapping(value = "/test")
public class TestController {
    private ITauthService authService;
    private ITuserService userService;
    @Autowired
    public TestController(ITauthService authService,ITuserService userService){
        this.authService = authService;
        this.userService = userService;
    }
    @RequestMapping(value = "/test.html")
    public String testMethod(){
        Tauth auth = new Tauth();
        auth.setAuthName("删除");
        auth.setAuthCode("delete");
        int result = authService.insert(auth);
        if(result>0){
            System.out.println("添加成功");
        }
        return "test.html";
    }

    @RequestMapping(value = "/insert-user.html")
    public String insertUser(){
        Tuser user = new Tuser();
        user.setUserName("张三");
        user.setUserSex(GenderEnum.MALE.getNum());
        user.setUserType(UserTypeEnum.USER.getNum());
        int result = userService.insert(user);
        if(result>0){
            return "添加成功";
        }else{
            return "添加失败";
        }
    }
}
